﻿using System.ComponentModel.DataAnnotations.Schema;
using System.Reflection;

namespace Dapper.ExpressionExtension.Resolvers
{
    /// <summary>
    /// 默认列名解析器
    /// </summary>
    public class DefaultColumnNameResolver : IColumnNameResolver
    {
        /// <summary>
        /// 解析列名，优先从[Column]属性中获取
        /// </summary>
        public virtual string ResolveColumnName(PropertyInfo propertyInfo)
        {
            var columnAttr = propertyInfo.GetCustomAttribute<ColumnAttribute>();
            return columnAttr != null ? columnAttr.Name : propertyInfo.Name;
        }
    }
}
